home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 301-325 / disk_319 / cnewssrc / cnews.orig.lzh / expire / superkludge < prev    next >
Text File  |  1989-06-27  |  1KB  |  50 lines

  1. #! /bin/sh
  2. # superkludge - implement the stupid Supersedes header for specific groups
  3.  
  4. # =()<. ${NEWSCONFIG-@<NEWSCONFIG>@}>()=
  5. . ${NEWSCONFIG-/usr/lib/news/bin/config}
  6.  
  7. PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH
  8. umask $NEWSUMASK
  9. trap "rm -f /tmp/sup*$$ ; exit 0" 0 1 2
  10.  
  11. verbose=
  12. case "$1" in
  13. -v)    verbose=yes ; shift ;;
  14. esac
  15.  
  16. for ng
  17. do
  18.     dir=`echo $ng | sed 's;\.;/;g'`
  19.     if test ! -d $NEWSARTS/$dir
  20.     then
  21.         echo "$0: no directory for newsgroup \`$ng'" >&2
  22.         exit 1
  23.     fi
  24.     cd $NEWSARTS/$dir
  25.     >/tmp/sup$$
  26.     for f in `ls | egrep '^[0-9]+$'`
  27.     do
  28.         awk 'BEGIN { mid = "xxx" }
  29.             /^$/ { exit }    # goes to END
  30.             /^Supersedes:[     ]/ { sup = $2 }
  31.             /^Message-ID:[     ]/ { mid = $2 }
  32.             END { print FILENAME, mid, sup ; exit }' $f >>/tmp/sup$$
  33.     done
  34.     awk 'NF > 3 || $2 !~ /^<.*>$/ || $3 !~ /^(<.*>)?$/' /tmp/sup$$ >/tmp/supx$$
  35.     if test -s /tmp/supx$$
  36.     then
  37.         echo "$0: message-id format problems:" >&2
  38.         cat /tmp/supx$$ >&2
  39.         exit 1
  40.     fi
  41.     awk 'NF == 3 { print $3 }' /tmp/sup$$ | sort >/tmp/supd$$
  42.     sort +1 /tmp/sup$$ -o /tmp/sup$$
  43.     join -j2 2 -o 2.1 /tmp/supd$$ /tmp/sup$$ >/tmp/supx$$
  44.     rm -f `cat /tmp/supx$$`
  45.     if test " $verbose" = " yes"
  46.     then
  47.         echo "`wc -l </tmp/supx$$` superseded in $ng"
  48.     fi
  49. done
  50.